<template>
    <el-form ref="form" :model="form" label-width="800px" class="form">
        <el-form-item :label="item.content" v-for="(item, index) in indexList" :key="item.id">
            <el-radio-group v-model="form[index]">
                <el-radio :label="item.point1">非常同意</el-radio>
                <el-radio :label="item.point2">比较同意</el-radio>
                <el-radio :label="item.point3">同意</el-radio>
                <el-radio :label="item.point4">不同意</el-radio>
                <el-radio :label="item.point5">非常不同意</el-radio>
            </el-radio-group>
        </el-form-item>
        <el-button @click="fillOut" type="primary">提 交</el-button>
    </el-form>
</template>

<script>
import { listIndex } from "@/api/bussiness/index";
import { fillOut, check } from "@/api/bussiness/point";
export default {
    data() {
        return {
            form: {},
            indexList: [],
            total: -1
        }
    },
    mounted() {
        this.getList()
    },
    methods: {
        /** 查询评价指标列表 */
        getList() {
            this.loading = true;
            listIndex({
                pageNum: 1,
                pageSize: 999999
            }).then(response => {
                this.indexList = response.rows;
                this.total = response.total;
            });
        },
        fillOut() {
            check().then(res => {
                let point = 0;
                let count = 0;
                for (let key in this.form) {
                    point += this.form[key];
                    count++;
                }
                if (count != this.total) {
                    this.$modal.msgWarning("请全部选择后提交。");
                    return;
                }
                this.loading = true;

                fillOut(point).then(response => {
                    this.$modal.msgSuccess("提交成功");
                });
            })


        },
    },
}
</script>

<style scoped>
.form {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    overflow: scroll;
}
</style>